<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" >

<title>mysql官方镜像8.0.29版本需要添加mysql-files映射 | janl&#39;s workspace</title>

<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">

<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.2/css/all.css" integrity="sha384-fnmOCqbTlWIlj8LyTjo7mOUStjsKC4pOpQbqyi7RrhN7udi9RwhKkMHpvLbHG9Sr" crossorigin="anonymous">
<link rel="shortcut icon" href="https://janl.gitee.io/favicon.ico?v=1658806429692">
<link rel="stylesheet" href="https://janl.gitee.io/styles/main.css">



<link rel="stylesheet" href="https://unpkg.com/aos@next/dist/aos.css" />
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>



    <meta name="description" content="原来用的是mysql:8.0的镜像，布署到测试服务器时，服务器上使用的镜像版本是8.0.29版本，结果导致docker-compose up时容器报错无法启动，经查错误日志发现了这一问题。
需要在原用 var/lib/mysql的基础上再添..." />
    <meta name="keywords" content="" />
  </head>
  <body>
    <div id="app" class="main">

      <div class="sidebar" :class="{ 'full-height': menuVisible }">
  <div class="top-container" data-aos="fade-right">
    <div class="top-header-container">
      <a class="site-title-container" href="https://janl.gitee.io">
        <img src="https://janl.gitee.io/images/avatar.png?v=1658806429692" class="site-logo">
        <h1 class="site-title">janl&#39;s workspace</h1>
      </a>
      <div class="menu-btn" @click="menuVisible = !menuVisible">
        <div class="line"></div>
      </div>
    </div>
    <div>
      
        
          <a href="/" class="site-nav">
            首页
          </a>
        
      
        
          <a href="/archives" class="site-nav">
            归档
          </a>
        
      
        
          <a href="/tags" class="site-nav">
            标签
          </a>
        
      
        
          <a href="/post/about" class="site-nav">
            关于
          </a>
        
      
    </div>
  </div>
  <div class="bottom-container" data-aos="flip-up" data-aos-offset="0">
    <div class="social-container">
      
        
      
        
      
        
      
        
      
        
      
    </div>
    <div class="site-description">
      道可道 非常道
    </div>
    <div class="site-footer">
      Powered by <a href="https://janl.gitee.io" target="_blank">Janl</a> | <a class="rss" href="https://janl.gitee.io/atom.xml" target="_blank">RSS</a>
    </div>
  </div>
</div>


      <div class="main-container">
        <div class="content-container" data-aos="fade-up">
          <div class="post-detail">
            <h2 class="post-title">mysql官方镜像8.0.29版本需要添加mysql-files映射</h2>
            <div class="post-date">2022-07-22</div>
            
              <div class="feature-container" style="background-image: url('https://janl.gitee.io/post-images/mysql-guan-fang-jing-xiang-8029-ban-ben-xu-yao-tian-jia-mysql-files-ying-she.png')">
              </div>
            
            <div class="post-content" v-pre>
              <p>原来用的是mysql:8.0的镜像，布署到测试服务器时，服务器上使用的镜像版本是8.0.29版本，结果导致docker-compose up时容器报错无法启动，经查错误日志发现了这一问题。<br>
需要在原用 var/lib/mysql的基础上再添加一条 var/lib/mysql-files这一路径的映射。</p>
<!-- more -->
<p>原配置文件如下：</p>
<pre><code>version: &quot;3&quot;
services:
  cloud-disk-db:
    image: mysql:8.0
    restart: always
    container_name: cloud-disk-db
    environment:
      MYSQL_ROOT_PASSWORD: 123456
      TZ: Asia/Shanghai
    ports:
      - 3306:3306
    volumes:
      - ./mysql/data:/var/lib/mysql
      - ./mysql/config/my.cnf:/etc/mysql/my.cnf
    command:
      --max_connections=1000
      --character-set-server=utf8mb4
      --collation-server=utf8mb4_general_ci
      --default-authentication-plugin=mysql_native_password

</code></pre>
<p>经排查错误信息后发现说需要多增加一个映射 ，指向 /var/lib/mysql-files</p>
<pre><code>version: &quot;3&quot;
services:
  *****-****-db:
    image: mysql:8.0.29
    restart: always
    container_name: ****-****-db
    environment:
      MYSQL_ROOT_PASSWORD: *******
      TZ: Asia/Shanghai
    ports:
      - 3306:3306
    volumes:
      - ./mysql/data:/var/lib/mysql
      - ./mysql/mysql-files:/var/lib/mysql-files
      - ./mysql/config/my.cnf:/etc/mysql/my.cnf
    command:
      --max_connections=1000
      --character-set-server=utf8mb4
      --collation-server=utf8mb4_general_ci
      --default-authentication-plugin=mysql_native_password
</code></pre>
<p>mysql配置文件如下：my.cnf</p>
<pre><code>[mysqld]
user=mysql
default-storage-engine=INNODB
character-set-server=utf8
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8
</code></pre>

            </div>
            
            
              <div class="next-post">
                <div class="next">下一篇</div>
                <a href="https://janl.gitee.io/post/django-da-bao-xia-zai-hou-shan-chu-wen-jian/">
                  <h3 class="post-title">
                    django打包下载后删除文件
                  </h3>
                </a>
              </div>
            

            

          </div>

        </div>
      </div>
    </div>

    <script src="https://unpkg.com/aos@next/dist/aos.js"></script>
<script type="application/javascript">

AOS.init();

var app = new Vue({
  el: '#app',
  data: {
    menuVisible: false,
  },
})

</script>


  <script src="//cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.5.1/build/highlight.min.js"></script>
  <script>
    hljs.initHighlightingOnLoad()
  </script>





  </body>
</html>
